<%@page import="com.crm.entity.User" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/temp.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<!-- InstanceEndEditable -->
<link href="<%=application.getContextPath()%>/css/css-crm.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.6.min.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-ui-1.8.17.custom.min.js"></script>	
<link rel="stylesheet" href="<%=application.getContextPath()%>/css/jquery-ui-1.8.17.custom.css"/>
<script language="JavaScript" src="<%=application.getContextPath()%>/js/gen_validatorv4.js" type="text/javascript" ></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.min.js"></script>

<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<div id="main">
  <%@ include file="common/header.jsp" %>
  
  <div id="content"><!-- InstanceBeginEditable name="EditRegion3" -->
    <div id="work-area2">
      <div class="heading2">My Account</div>
      <div id="resultMsg" align="center" class="result_msg" >
      <%
      	
      if(request.getAttribute("msg")!=null){
    	  out.println(request.getAttribute("msg"));
      }
      %>
      </div>
	  <%
	  	User u=(User)session.getAttribute("user");
	  %>
      <div class="boxIFS">
        <form id="form1" name="form1" method="post" action="<%=application.getContextPath()%>/account/update.do" enctype="multipart/form-data">
          <table width="100%" border="0"  style="float: right;"  cellspacing="0" cellpadding="5" align="center">
            <tr>
              <td align="right">&nbsp;</td>
              <td align="right" valign="middle">&nbsp;</td>
              <td align="right" valign="middle">&nbsp;</td>
              <td align="left" valign="middle">&nbsp;</td>
              <td align="left" valign="middle">&nbsp;</td>
            </tr>
            <tr>
            <input type="hidden" name="userId" value="<%=u.getId()%>"/>
              <td width="19%" align="right"><strong>First Name:</strong></td>
              <td width="24%" align="right" valign="middle"><label>
                <input name="fname" type="text" class="form" id="fnameid" value="<%=u.getFirstName()%>"/>
              </label>              </td>
              <td width="22%" align="right" valign="middle">&nbsp;</td>
              <td width="31%" align="left" valign="middle">&nbsp;</td>
              <td width="4%" align="left" valign="middle">&nbsp;</td>
            </tr>
            <tr>
              <td width="19%" align="right"><strong>Last Name:</strong></td>
              <td width="24%" align="right" valign="middle"><label>
                <input name="lname" type="text" class="form" id="lnameid" value="<%=u.getLastName()%>"/>
              </label>              </td>
              <td width="22%" align="right" valign="middle">&nbsp;</td>
              <td width="31%" align="left" valign="middle">&nbsp;</td>
              <td width="4%" align="left" valign="middle">&nbsp;</td>
            </tr>
            <tr>
              <td width="19%" align="right"><strong>Email Id:</strong></td>
              <td width="24%" align="right" valign="middle"><label>
                <input name="email" type="text" class="form" id="emailid" value="<%=u.getEmail()%>"/>
              </label>              </td>
              <td width="22%" align="right" valign="middle">&nbsp;</td>
              <td width="31%" align="left" valign="middle">&nbsp;</td>
              <td width="4%" align="left" valign="middle">&nbsp;</td>
            </tr>
            <tr>
              <td width="19%" align="right"><strong>Email Pwd:</strong></td>
              <td width="24%" align="right" valign="middle"><label>
                <input name="emailpwd" type="password" class="form" id="emailpwdid" value="<%=u.getEmailPwd()%>"/>
              </label>              </td>
              <td width="22%" align="right" valign="middle">&nbsp;</td>
              <td width="31%" align="left" valign="middle">&nbsp;</td>
              <td width="4%" align="left" valign="middle">&nbsp;</td>
            </tr>
            <tr>
              <td width="19%" align="right"><strong>User Name:</strong></td>
              <td width="24%" align="right" valign="middle"><label>
                <input name="uname" type="text" class="form" id="unameid" value="<%=u.getUserName()%>"/>
              </label>              </td>
              <td width="22%" align="right" valign="middle">&nbsp;</td>
              <td width="31%" align="left" valign="middle">&nbsp;</td>
              <td width="4%" align="left" valign="middle">&nbsp;</td>
            </tr>
            <tr>
              <td align="right"><strong>ACRM Old Password:</strong></td>
              <td align="right" valign="top"><input name="oldpwd" type="password" class="form" id="oldpwdid" value="<%=u.getPassword()%>"/></td>
              <td align="left" valign="middle">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td align="right"><strong>ACRM New Password:</strong></td>
              <td align="right" valign="top">
              <input name="newpwd" type="password" class="form" placeholder="Your New Password"/></td>
              <td align="left" valign="middle">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td align="right"><strong>ACRM Confirm password:</strong></td>
              <td align="right" valign="top">
              <input name="confpwd" type="password" class="form"  placeholder="Confirm Password"/></td>
              <td align="left" valign="middle">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
           
            <tr>
              <td align="right">&nbsp;</td>
              <td colspan="3" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td width="31%">
                  <input type="submit"  class="button" value="Update" onclick="javascript:return validate();"/></td>
                  <td width="69%">&nbsp;</td>
                </tr>
              </table></td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td align="right">&nbsp;</td>
              <td colspan="3" align="center" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</td>
            </tr>
          </table>
        </form>
      </div>
    </div>
    <!-- InstanceEndEditable -->
  </div><div id="footer"></div>  
</div>
</body>
<!-- InstanceEnd --></html>
<script type="text/javascript">
function validate(){
	var fname=$("#fnameid").val();
	var lname=$("#lnameid").val();
	var emailid=$("#emailid").val();
	var emailpwd=$("#emailpwdid").val();
	var uname=$("#unameid").val();
	var oldpwd=$("#oldpwdid").val();
	var newpwd=$("#newpwdid").val();
	var confpwd=$("#confpwdid").val();
	if(fname==null || fname==""){
		alert("First name Cannot Be Null");
		$("#fnameid").focus();
		return false;
	}
	if(lname==null || lname==""){
		alert("Last name Can Not Be Null");
		$("#lnameid").focus();
		return false;
	}
	if(emailid==null || emailid==""){
		alert("Email Id Can Not Be Null");
		$("#emailid").focus();
		return false;
	}
	if(emailpwd==null || emailpwd==""){
		alert("Please Enter Your Email Password");
		$("#emailpwdid").focus();
		return false;
	}
	if(uname==null || uname==""){
		alert("Please Enter Username");
		$("#unameid").focus();
		return false;
	}
	if(oldpwd==null || oldpwd==""){
		alert("Please Enter your Old password");
		$("#oldpwdid").focus();
		return false;
	}
	if(newpwd!=null || newpwd!=""){
		if(confpwd==null && newpwd!=confpwd){
			alert("Your New Password And Confirm password Should Match");
			$("#oldpwdid").focus();
			return false;
		}
	}
}
</script>
